﻿<!--
 Copyright (c) 2014 Regents of the University of Michigan

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-->

<UserControl x:Class="PluginTester.MainWindow"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" d:DesignHeight="430" d:DesignWidth="1036">
    <UserControl.Resources>
        <Style x:Key="isPlanSum" TargetType="Label">
            <Style.Triggers>
                <DataTrigger Binding="{Binding Path=IsPlanSum}" Value="True">
                    <Setter Property="Visibility" Value="Visible"/>
                </DataTrigger>
                <DataTrigger Binding="{Binding Path=IsPlanSum}" Value="False">
                    <Setter Property="Visibility" Value="Hidden"/>
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </UserControl.Resources>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="30"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="40"/>
        </Grid.RowDefinitions>
        <Label Grid.Column="0" Grid.Row="0" Content="Select Patient"/>
        <!-- Patients -->
        <DataGrid Grid.Column="0" Grid.Row="1" Name="dtgPatients" ItemsSource="{Binding Patients}" AutoGenerateColumns="False" IsReadOnly="True" SelectionMode="Single" SelectionUnit="FullRow" SelectedItem="{Binding SelectedPatient}" SelectedCellsChanged="dtgPatients_SelectedCellsChanged">
            <DataGrid.Columns>
                <DataGridTextColumn Header="Last Name" Binding="{Binding FirstName}" Width="*"/>
                <DataGridTextColumn Header="First Name" Binding="{Binding LastName}" Width="*"/>
                <DataGridTextColumn Header="Id" Binding="{Binding PatientId}" Width="*"/>
            </DataGrid.Columns>
        </DataGrid>
        
        <!-- Courses-->
        <Label Grid.Column="1" Grid.Row="0" Content="Select Course"/>
        <ListBox Grid.Column="1" Grid.Row="1" ItemsSource="{Binding PatientCourses}">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <RadioButton GroupName="grmCourses" IsChecked="{Binding IsSelected}" Content="{Binding CourseId}" Checked="RadioButton_Checked"/>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
        
        <!-- Plans in Scope-->
        <Label Grid.Column="2" Grid.Row="0" Content="Select Planning Items in Scope"/>
        <ListBox Grid.Column="2" Grid.Row="1" ItemsSource="{Binding CoursePlanItems}">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <CheckBox IsChecked="{Binding IsInScope, Mode=TwoWay}" Checked="CheckBox_Checked" Unchecked="CheckBox_Unchecked">
                        <CheckBox.Content>
                            <StackPanel Orientation="Horizontal">
                                <Label Content="{Binding pItemId}" HorizontalAlignment="Left" VerticalAlignment="Center"/>
                                <Label Style="{StaticResource isPlanSum}" Content="+" Foreground="Red" VerticalAlignment="Center" HorizontalAlignment="Right"/>
                            </StackPanel>
                        </CheckBox.Content>
                    </CheckBox>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
        
        <!-- Plans-->
        <Label Grid.Column="3" Grid.Row="0" Content="Select Opened Planning Item"/>
        <ListBox Grid.Column="3" Grid.Row="1" ItemsSource="{Binding PlansInScope}">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <RadioButton GroupName="grpOpenedPitems" IsChecked="{Binding IsOpened}" Content="{Binding pItemId}" Checked="OpenPatient_Checked" VerticalAlignment="Center"/>
                        <Label Style="{StaticResource isPlanSum}" Content="+" Foreground="Red" HorizontalAlignment="Right" VerticalAlignment="Center"/>
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
        
        <!--<TabControl Grid.Column="3" Grid.Row="1">
            <TabItem Header="PlanSetups" Name="tabPlans">
                <ListBox Name="lstPlans" ItemsSource="{Binding PlanSetupIds}"  Margin="5,0,5,0" SelectionChanged="lstPlans_SelectionChanged"/>
            </TabItem>
            <TabItem Header="PlanSums" Name="tabSums">
                <ListBox Name="lstSums" ItemsSource="{Binding PlanSumsIds}"  Margin="5,0,5,0" SelectionChanged="lstSums_SelectionChanged"/>
            </TabItem>
        </TabControl>-->
        
        <!-- The Start button-->
        <Button Grid.Row="2" Grid.ColumnSpan="4" Name="btnStart" Content="Start Plugin" VerticalAlignment="Center" Width="100" IsEnabled="False" Click="btnStart_Click"/>
        
    </Grid>
</UserControl>
